﻿using AutoMapper;
using MediatR;
using S.Eartag.API.Application.Command.SheepFileConditionCommand;
using S.Eartag.Domain.Model;
using S.Eartag.Infrastructure.Impl;
using S.Eartag.Infrastructure.Interface;
using System.Security.Cryptography;

namespace S.Eartag.API.Application.CommandHandlers.SheepFileConditionCommandHandler
{
    public class SheepFileConditionDeleteCommandHandler : IRequestHandler<SheepFileConditionDeleteCommand, int>
    {
        private readonly ISheepFileRepository sheepFileRepository;
        private readonly IMapper mapper;
        public SheepFileConditionDeleteCommandHandler(ISheepFileRepository sheepFileRepository, IMapper mapper)
        {
            this.sheepFileRepository = sheepFileRepository;
            this.mapper = mapper;
        }

        public async Task<int> Handle(SheepFileConditionDeleteCommand request, CancellationToken cancellationToken)
        {
            var res = await sheepFileRepository.Get(request.id);
            res.IsDel = true;
            var info = sheepFileRepository.Update(res);
            return await info;
        }
    }
}
